package com.craftplay.dao;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.craftplay.model.PayRedPackage;

public class PayRedPackageSqlProvider {

    public String insertSelective(PayRedPackage record) {
        BEGIN();
        INSERT_INTO("pay_red_package");
        
        if (record.getId() != null) {
            VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getOuttradeno() != null) {
            VALUES("outTradeNo", "#{outtradeno,jdbcType=VARCHAR}");
        }
        
        if (record.getRedoutreadeno() != null) {
            VALUES("redOutReadeNo", "#{redoutreadeno,jdbcType=VARCHAR}");
        }
        
        if (record.getUserid() != null) {
            VALUES("userId", "#{userid,jdbcType=INTEGER}");
        }
        
        if (record.getMoney() != null) {
            VALUES("money", "#{money,jdbcType=INTEGER}");
        }
        
        if (record.getCreatetime() != null) {
            VALUES("createTime", "#{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getStatus() != null) {
            VALUES("status", "#{status,jdbcType=INTEGER}");
        }
        
        if (record.getPaytime() != null) {
            VALUES("payTime", "#{paytime,jdbcType=TIMESTAMP}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(PayRedPackage record) {
        BEGIN();
        UPDATE("pay_red_package");
        
        if (record.getOuttradeno() != null) {
            SET("outTradeNo = #{outtradeno,jdbcType=VARCHAR}");
        }
        
        if (record.getRedoutreadeno() != null) {
            SET("redOutReadeNo = #{redoutreadeno,jdbcType=VARCHAR}");
        }
        
        if (record.getUserid() != null) {
            SET("userId = #{userid,jdbcType=INTEGER}");
        }
        
        if (record.getMoney() != null) {
            SET("money = #{money,jdbcType=INTEGER}");
        }
        
        if (record.getCreatetime() != null) {
            SET("createTime = #{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getStatus() != null) {
            SET("status = #{status,jdbcType=INTEGER}");
        }
        
        if (record.getPaytime() != null) {
            SET("payTime = #{paytime,jdbcType=TIMESTAMP}");
        }
        
        WHERE("id = #{id,jdbcType=INTEGER}");
        
        return SQL();
    }
}